package com.three.lab.util;

import android.content.Context;

import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.interfaces.OnConfirmListener;
import com.three.lab.R;

public class XpopupUtil {

    private OnPopupOkListener listener;

    public void setListener(OnPopupOkListener listener) {
        this.listener = listener;
    }

    public static void showOnce(Context content,String message, OnPopupOkListener mlistener){

        new XPopup.Builder(content)
                .isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这
                .isLightNavigationBar(true)
                .asConfirm(content.getString(R.string.kindly_reminder), message, content.getString(R.string.cancel), content.getString(R.string.confirm), new OnConfirmListener() {
                    @Override
                    public void onConfirm() {
                        if (mlistener != null) {
                            mlistener.onPopupConfirm();
                        }
                    }
                }, null, false)
                .show();
    }

    public static void showTips(Context content,String message){

        new XPopup.Builder(content)
                .isDestroyOnDismiss(true) //对于只使用一次的弹窗，推荐设置这
                .isLightNavigationBar(true)
                .asConfirm(content.getString(R.string.kindly_reminder), message, content.getString(R.string.cancel), content.getString(R.string.i_know), new OnConfirmListener() {
                    @Override
                    public void onConfirm() {

                    }
                }, null, true)
                .show();
    }

    public interface OnPopupOkListener{
        void onPopupConfirm();
    }
}
